﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Maticsoft.Common;

namespace Golf.WebUI.AdminShow.CustomerManagement
{
    public partial class Golf_UserAdd : Golf.WebUI.App_code.ValidateLogin
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        protected void btnSave_Click(object sender, EventArgs e)
        {

            string strErr = "";
            if (!PageValidate.IsNumber(txtUserType.Text))
            {
                strErr += "用户类型格式错误！\\n";
            }
            if (this.txtFristName.Text.Trim().Length == 0)
            {
                strErr += "姓不能为空！\\n";
            }
            if (this.txtLastName.Text.Trim().Length == 0)
            {
                strErr += "名不能为空！\\n";
            }
            if (this.txtPassWord.Text.Trim().Length == 0)
            {
                strErr += "用户密码不能为空！\\n";
            }
            if (this.txtEmail.Text.Trim().Length == 0)
            {
                strErr += "邮箱不能为空！\\n";
            }
            if (!PageValidate.IsNumber(txtState.Text))
            {
                strErr += "状态 1启用0禁用格式错误！\\n";
            }
            if (!PageValidate.IsDateTime(txtRegisterTime.Text))
            {
                strErr += "注册时间格式错误！\\n";
            }
            if (!PageValidate.IsDateTime(txtLoginTime.Text))
            {
                strErr += "登陆时间格式错误！\\n";
            }
            if (!PageValidate.IsDateTime(txtEndtime.Text))
            {
                strErr += "推出时间格式错误！\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            int UserType = int.Parse(this.txtUserType.Text);
            string FristName = this.txtFristName.Text;
            string LastName = this.txtLastName.Text;
            string PassWord = this.txtPassWord.Text;
            string Email = this.txtEmail.Text;
            int State = int.Parse(this.txtState.Text);
            DateTime RegisterTime = DateTime.Parse(this.txtRegisterTime.Text);
            DateTime LoginTime = DateTime.Parse(this.txtLoginTime.Text);
            DateTime Endtime = DateTime.Parse(this.txtEndtime.Text);

            Golf.Model.Golf_User model = new Golf.Model.Golf_User();
            model.UserType = UserType;
            model.FristName = FristName;
            model.LastName = LastName;
            model.PassWord = PassWord;
            model.Email = Email;
            model.State = State;
            model.RegisterTime = RegisterTime;
            model.LoginTime = LoginTime;
            model.Endtime = Endtime;

            Golf.BLL.Golf_User bll = new Golf.BLL.Golf_User();
            bll.Add(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功！", "add.aspx");

        }


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("list.aspx");
        }
    }
}